package com.example.demo.config;

import com.example.demo.filter.FirstFilter;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 过滤器配置类
 * @author wch
 */
@Configuration
public class FilterConfig {

    /**
     * 注册配置的过滤器
     * addUrlPatterns 表示需要过滤的请求地址
     * @return
     */
    @Bean
    public FilterRegistrationBean myFilterRegistration() {
        FilterRegistrationBean registration = new FilterRegistrationBean(new FirstFilter());
        registration.addUrlPatterns("/user/list");
        registration.setName("myFilter");
        return registration;
    }
}
